<?php
/**
 * Created by PhpStorm.
 * User: 快定
 * Date: 2021/9/13
 * Time: 11:40
 */

//prefix路由前缀，namespace公共命名空间
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function () {
    //登录页面展示
    Route::get('login', 'LoginController@index')->name('admin.login');
    //登录逻辑处理
    Route::post('login', 'LoginController@login')->name('admin.login');

    Route::group(['middleware' => ['checkAdmin'],'as' => 'admin.'], function () {
        //后台首页
        Route::get('index', 'IndexController@index')->name('index');
        //欢迎页面
        //Route::get('welcome','IndexController@welcome')->name('admin.welcome')->middleware('checkAdmin');
        Route::get('welcome', 'IndexController@welcome')->name('welcome');
        //退出登录
        Route::get('logout', 'IndexController@logout')->name('logout');
        //用户页面展示
        Route::get('user/index', 'UserController@index')->name('user.index');
        //用户新增页面
        Route::get('user/create', 'UserController@create')->name('user.create');
        //用户新增逻辑
        Route::post('user/add', 'UserController@add')->name('user.add');
        //用户删除
        Route::delete('user/del/{id}', 'UserController@del')->name('user.del');
        //用户恢复
        Route::get('user/reset/{id}','UserController@reset')->name('user.reset');
        //批量删除
        Route::delete('user/delAll','UserController@delAll')->name('user.delAll');
        //修改页面展示
        Route::get('user/edit/{id}','UserController@edit')->name('user.edit');
        //修改页面
        Route::put('user/edit/{id}','UserController@update')->name('user.edit');
        //定义权限资源路由
        Route::resource('auth','AuthController');
        //定义角色资源路由
        Route::resource('role','RoleController');
        //恢复删除的角色
        Route::get('role/reset/{id}','RoleController@reset')->name('role.reset');
        //角色分配权限
        Route::get('role/auth/{role}','RoleController@auth')->name('role.auth');
        Route::post('role/authSave/{role}','RoleController@authSave')->name('role.authSave');

        //用户授予角色
        Route::match(['get','post'],'user/role/{user}','UserController@role')->name('user.role');
        //文章资源路由
        Route::resource('article','ArticleController');
        //房源资源路由
        Route::resource('fangattr','FangAttrController');
        //房东信息导出
        Route::get('fangowners/export', 'FangOwnersController@export')->name('fangowners.export');
        //房东资源路由
        Route::resource('fangowners','FangOwnersController');
    });
});